from sqlalchemy import or_, exc

from app.config.db import DBUtils


class SysReportConfigService:

    def __init__(self):
        self.db_utils = DBUtils()

    # 新增报告信息
    def insert_data(self, session, sysReportConfigModel):
        try:
            session.add(sysReportConfigModel)
            session.commit()
            return 1
        except exc.SQLAlchemyError as e:
            try:
                self.db_utils.rollback()
            except Exception as rollback_error:
                print(f"Failed to rollback transaction: {rollback_error}")
            return 0
        finally:
            try:
                self.db_utils.remove_session()
            except Exception as remove_error:
                print(f"Failed to rollback transaction: {remove_error}")
